package engine.systems.control.keyboardControl
{
	import engine.classes.enumerations.SystemPriority;
	import engine.systems.update.GameSystem;
	import engine.utils.Key;
	
	public class KeyboardControlSystem extends GameSystem
	{
		public function KeyboardControlSystem()
		{
			super(KeyboardControlNode, updateNode);
			
			this.priority = SystemPriority.UPDATE;
		}
		
		private function updateNode(node:KeyboardControlNode, time:Number):void
		{
			if(node.control.locked) return;
			
			if(Key.isDown(node.control.up)) 	node.spatial.y -= node.control.rate * time;
			if(Key.isDown(node.control.down)) 	node.spatial.y += node.control.rate * time;
			
			if(Key.isDown(node.control.left))  	node.spatial.x -= node.control.rate * time;
			if(Key.isDown(node.control.right)) 	node.spatial.x += node.control.rate * time;
		}
	}
}